<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page import="java.util.Map" %>
<%@ page import="java.util.List" %>
<%@ page import="java.util.Collection" %>
<%@ page import="java.util.ArrayList" %><%--
  Created by IntelliJ IDEA.
  User: LiHengfei
  Date: 2021/2/9
  Time: 23:00
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%
    Map<String, String> errors  = (Map<String, String>)request.getAttribute("errors");      // 表单错误信息
    Map<String, String> formData = (Map<String, String>) request.getAttribute("formData");  // 已填信息
%>
<html>
<head>
    <title>新顾客注册 - E速订餐</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0-beta1/dist/css/bootstrap.min.css" rel="stylesheet"
          integrity="sha384-giJF6kkoqNQ00vy+HMDP7azOuL0xtbfIcaT9wjKHr8RbDVddVHyTfAAsrekwKmP1" crossorigin="anonymous">
</head>
<body>
<div class="container">
    <div class="head">
        <h1>新顾客注册</h1>
    </div>
    <form action="customer-register" method="post">
        <c:if test="${errors.size() > 0}">
            <div class="text-danger">
                <ul>
                    <c:forEach items="${errors.values()}" var="error">
                        <li>${error}</li>
                    </c:forEach>
                </ul>
            </div>
        </c:if>

        <div class="row g-2">
            <div class="col-sm col-md-6">
                <label for="tbUsername" class="form-label">用户名：</label>
                <input type="text" name="username" id="tbUsername"
                       class="form-control <%= errors.containsKey("tbUsername") ? "is-invalid" : "" %>"
                       value="${ param.username }">
            </div>

            <div class="col-sm col-md-6">
                <label for="tbRealName" class="form-label">真实姓名：</label>
                <input type="text" id="tbRealName" name="realName"
                       class="form-control <%= errors.containsKey("tbRealName") ? "is-invalid" : "" %>"
                       value="${ param.realName }">
            </div>

            <div class="col-sm col-md-6">
                <label for="tbPassword" class="form-label">密码：</label>
                <input type="password" id="tbPassword" name="password"
                       class="form-control <%= errors.containsKey("tbPassword") ? "is-invalid" : "" %>">
            </div>

            <div class="col-sm col-md-6">
                <label for="tbPasswordConfirm" class="form-label">确认密码：</label>
                <input type="password" id="tbPasswordConfirm" name="passwordConfirm"
                       class="form-control <%= errors.containsKey("tbPasswordConfirm") ? "is-invalid" : "" %>">
            </div>

            <div class="col-sm col-md-6">
                <label for="tbPhoneNumber" class="form-label">电话：</label>
                <input type="text" id="tbPhoneNumber" name="phoneNumber"
                       class="form-control <%= errors.containsKey("tbPhoneNumber") ? "is-invalid" : "" %>"
                       value="${ param.phoneNumber }">
            </div>

            <div class="col-sm col-md-6">
                <label for="tbEmail" class="form-label">Email：</label>
                <input type="text" id="tbEmail" name="email"
                       class="form-control <%= errors.containsKey("tbEmail") ? "is-invalid" : "" %>"
                       value="${ param.email }">
            </div>

            <div class="col-sm-12">
                <label for="tbDeliveryAddress" class="form-label">送餐地址：</label>
                <input type="text" id="tbDeliveryAddress" name="deliveryAddress"
                       class="form-control <%= errors.containsKey("tbDeliveryAddress") ? "is-invalid" : "" %>"
                       value="${ param.deliveryAddress }">
            </div>
        </div>
        <div class="row">
            <div class="col-sm text-center">
                <button type="submit" class="btn btn-primary">确定</button>
            </div>
        </div>

    </form>
</div>
</body>
</html>
